package cn.xspace.chatui.bean;

import com.xspace.android.xafcommon.been.BaseEntity;
import cn.xspace.library.bean.Type;
import cn.xspace.library.util.MsgType;

/**
 * Created by liuchen on 2016/10/11.
 */

public class MessageEntity extends BaseEntity {

    public String inserttime = "";
    /**
     * 0：通知公告；1：微农信；2：单聊；3：群聊 4 农技员沟通
     */
    public int msg_type = MsgType.NOTICE.toNumber();
    public String msg_logo = "";
    public String msg_sender_id = "";
    public String msg_sender_name = "";
    public String msg_receiver_id = "";
    public String msg_receiver_name = "";
    public int msg_unread_count = 0;
    public String user_list_name = "";
    /**
     * 提醒状态 0:提醒；1：不接受提醒；
     */
    public int msg_warn_status = WarnStatus.WARN.toNumber();
    public String msg_last_time = "";
    /**
     * 0：【文本】；1：【图片】；2：【语音】；3：【图文】；4：【视频】；5：【位置】；6：【系统提示】7：【文件】
     */
    public int msg_content_type = ContentType.TXT.toNumber();
    public String msg_content = "";
    /**
     * 最新消息内容发送状态 一般是表示最新消息为我发送的，切未发送成功；若为0，表示未发送成功；1;发送成功；包含群聊单聊两种情况。-1表示此条消息为撤销状态；UI  红色感叹号；
     */
    public int msg_send_status = MsgSendStatus.SUCCESS.toNumber();
    public String msg_group_id = "";
    public int tip_type = 0;
    public String msg_group_name = "";
    public int msg_index = 0;
    public boolean isRead = false;
    public String platForm = "";
    public int isShow = 1;
    public int group_type = Type.GroupType.TEMP_GROUP;
    public String user_sex = "";
    public int group_member = 0;

    //表单Id
    public String form_id = "";
    public String form_name = ""; //17.6.14加表单名字,没加入数据库字段,仅用于通知栏推送使用
    //表单url
    public String form_url = "";
    //表单类型
    public int form_type = 1;
    public int form_status = -1;

    public MessageEntity chatRecord2messageRecord(MsgRecordEntity entity) {
        this.msg_sender_id = entity.msg_sender_id;
        this.msg_content = entity.msg_content;
        this.msg_content_type = entity.msg_content_type;
        this.msg_last_time = entity.msg_last_time;
        this.isRead = true;
        this.msg_group_id = entity.msg_group_id;
        this.msg_group_name = entity.msg_group_name;
        this.msg_type = entity.msg_type;
        return this;
    }

    @Override
    public String toString() {
        return "MessageEntity{" +
                "inserttime='" + inserttime + '\'' +
                ", msg_type=" + msg_type +
                ", msg_logo='" + msg_logo + '\'' +
                ", msg_sender_id='" + msg_sender_id + '\'' +
                ", msg_sender_name='" + msg_sender_name + '\'' +
                ", msg_receiver_id='" + msg_receiver_id + '\'' +
                ", msg_receiver_name='" + msg_receiver_name + '\'' +
                ", msg_unread_count=" + msg_unread_count +
                ", user_list_name='" + user_list_name + '\'' +
                ", msg_warn_status=" + msg_warn_status +
                ", msg_last_time='" + msg_last_time + '\'' +
                ", msg_content_type=" + msg_content_type +
                ", msg_content='" + msg_content + '\'' +
                ", msg_send_status=" + msg_send_status +
                ", msg_group_id='" + msg_group_id + '\'' +
                ", tip_type=" + tip_type +
                ", msg_group_name='" + msg_group_name + '\'' +
                ", msg_index=" + msg_index +
                ", isRead=" + isRead +
                ", platForm='" + platForm + '\'' +
                ", isShow=" + isShow +
                ", group_type=" + group_type +
                ", user_sex='" + user_sex + '\'' +
                ", group_member=" + group_member +
                '}';
    }

    public enum ContentType {
        PICTURE(0, "[图片]"),
        VOICE(1, "[语音]"),
        VEDIO(2, "[视频]"),
        TXT(3, "[文本]"),
        OTHER(4, "[链接]"),
        FILE(5, "[文件]"),
        SYSTEM_WARN(6, "[系统消息]"),
        LOCATION(7, "[位置]");
        private int INum = 0;
        private String IStr = "";

        /* 构造器，记住喇，必须是私有的~ */
        private ContentType(int iNum, String showTxt) {
            this.INum = iNum;
            this.IStr = showTxt;
        }

        /* 用这个方法代替ordinal()方法，安全，专业，包退包换~ */
        public int toNumber() {
            return this.INum;
        }

        public String getTxt() {
            return this.IStr;
        }
    }

    public enum WarnStatus {
        WARN(0),
        NOT_WARN(1);
        private int INum = 0;

        /* 构造器，记住喇，必须是私有的~ */
        private WarnStatus(int iNum) {
            this.INum = iNum;
        }

        /* 用这个方法代替ordinal()方法，安全，专业，包退包换~ */
        public int toNumber() {
            return this.INum;
        }
    }

    public enum MsgSendStatus {
        FAILED(0),
        SUCCESS(1),
        CANCEL(-1),
        IN_PROGRESS(2),

        NOT_SEND(3);

        private int INum = 0;

        /* 构造器，记住喇，必须是私有的~ */
        private MsgSendStatus(int iNum) {
            this.INum = iNum;
        }

        /* 用这个方法代替ordinal()方法，安全，专业，包退包换~ */
        public int toNumber() {
            return this.INum;
        }
    }

    public enum SystemType {
        Invite(1),
        GroupOwnerChange(2),
        GroupRemoveMember(3),
        GroupNameChange(4),
        WithDraw(5),
        MemberExit(6);

        private int INum = 0;

        /* 构造器，记住喇，必须是私有的~ */
        private SystemType(int iNum) {
            this.INum = iNum;
        }

        public int toNumber() {
            return this.INum;
        }

    }

}
